package ca.psquared.superbrixgame;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;

public class Block implements IBlock {

    private Image image;
    private int x;
    private int y;

    public Block(Image image, int x, int y) {
        this.image = image.copy();
        this.x = x;
        this.y = y;
    }

    @Override
    public Image getImage() {
        return image;
    }

    @Override
    public void setImage(Image image) {
        this.image = image;
    }

    @Override
    public int getX() {
        return x;
    }

    @Override
    public void setX(int x) {
        this.x = x;
    }

    @Override
    public int getY() {
        return y;
    }

    @Override
    public void setY(int y) {
        this.y = y;
    }

    @Override
    public void render(Graphics graphics) {
        final Image image1 = getImage();
        final int x1 = getX() * GameSettings.BLOCK_SIZE;
        final int y1 = getY() * GameSettings.BLOCK_SIZE;

        graphics.drawImage(image1, x1, y1);
    }

    @Override
    public String toString() {
        return "Block{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
}
